package reading.common.pojos;

import lombok.Data;
import reading.common.enums.ErrorEnum;
import reading.common.enums.IBaseEnum;

/**
 * Project: message-management
 * Package: com.mm.web.reqpojo
 *
 * @author : txw
 * @date : 2018/4/12 18:30
 */
@Data
public class Success {
    private int errCode;
    private String errMsg;
    private Object data;
    private Object stacks;

    public Success(int errCode, String errMsg, Object data, Object stacks) {
        this.errCode = errCode;
        this.errMsg = errMsg;
        this.data = data;
        this.stacks = stacks;
    }

    public static Success error(IBaseEnum iBaseEnum) {
        return new Success(iBaseEnum.getValue(), iBaseEnum.getName(), iBaseEnum.getName(), null);
    }

    public static Success success(int errCode, String errMsg, Object data, Object stacks) {
        return new Success(errCode, errMsg, data, stacks);
    }

    public static Success success(String data) {
        return new Success(ErrorEnum.SUCCESS.getValue(), data, data, null);
    }

    public static Success success(Object data) {
        return new Success(ErrorEnum.SUCCESS.getValue(), ErrorEnum.SUCCESS.getName(), data, null);
    }

    public static Success login(Object data) {
        return new Success(ErrorEnum.LOGIN_SUCCESS.getValue(), ErrorEnum.LOGIN_SUCCESS.getName(), data, null);
    }

    public static Success authBeond() {
        return new Success(ErrorEnum.AUTH_BEYOND.getValue(), ErrorEnum.AUTH_BEYOND.getName(), null, null);
    }

    public static Success success() {
        return new Success(ErrorEnum.SUCCESS.getValue(), ErrorEnum.SUCCESS.getName(), null, null);
    }

    public static Success nullData() {
        return new Success(ErrorEnum.NOT_FIND_DATA.getValue(), ErrorEnum.NOT_FIND_DATA.getName(), null, null);
    }

}
